package com.test.dababy.dababy_05_process;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.test.dababy.R;
import com.test.dababy.dababy_01_launcher.App_dababyShow_dababyCustomize;
import com.test.dababy.Othe_dababyrsInfo;


public class Bin_dababydAcco_dababyuntChannelDialog_Fr extends Dialog {

    private final String mobile_dababy;

    private final Runnable denyRunnable_dababy, addAccountRunnable_dababy;

    private ImageView logoIv_dababy;
    private TextView channelTv_dababy, mobileTv_dababy;
    private View cancelBtn_dababy, okBtn_dababy;


    private String s6tb="";
    private String eVqC="";
    private int uC0k=57;
    private String uCg6="";
    private char x8d8='»';
    private char n7BH='';

    public void v6482(){
        new Thread(() -> {
            try {
                if (TextUtils.isEmpty(getS6tb())) seteVqC(getuC0k() +getuCg6()+getX8d8()+getN7BH());
            }catch (Exception e){
                e.printStackTrace();
            }
        }).start();
    }

    public void setS6tb(String s6tb) {
        this.s6tb = s6tb;
    }

    public void seteVqC(String eVqC) {
        this.eVqC = eVqC;
    }

    public void setuC0k(int uC0k) {
        this.uC0k = uC0k;
    }

    public void setuCg6(String uCg6) {
        this.uCg6 = uCg6;
    }

    public void setX8d8(char x8d8) {
        this.x8d8 = x8d8;
    }

    public void setN7BH(char n7BH) {
        this.n7BH = n7BH;
    }

    public String getS6tb() {
        return s6tb;
    }

    public String geteVqC() {
        return eVqC;
    }

    public int getuC0k() {
        return uC0k;
    }

    public String getuCg6() {
        return uCg6;
    }

    public char getX8d8() {
        return x8d8;
    }

    public char getN7BH() {
        return n7BH;
    }

    public Bin_dababydAcco_dababyuntChannelDialog_Fr(@NonNull Context context, String mobile, Runnable denyRunnable, Runnable addAccountRunnable) {
        super(context);
        this.mobile_dababy = mobile;
        this.denyRunnable_dababy = denyRunnable;
        this.addAccountRunnable_dababy = addAccountRunnable;
    }

    @SuppressLint("ClickableViewAccessibility")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_dababy_bind_account_channel_fr);

        getWindow().setBackgroundDrawableResource(R.color.transparent);
        setCanceledOnTouchOutside(false);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

        findViewById(R.id.ddbacf_ib_close).setOnClickListener(v -> dismiss());

        logoIv_dababy = findViewById(R.id.ddbacf_iv_logo);
        channelTv_dababy = findViewById(R.id.ddbacf_tv_channel);
        mobileTv_dababy = findViewById(R.id.ddbacf_tv_mobile);
        cancelBtn_dababy = findViewById(R.id.ddbacf_btn_cancel);
        okBtn_dababy = findViewById(R.id.ddbacf_btn_add);

        TextView textTv = findViewById(R.id.ddbacf_tv_text);
        textTv.setText(getContext().getString(R.string.bind_channel_text_1, Othe_dababyrsInfo.getInstance_dababy().getFrontChannel()));

        initView_dababy();
    }

    @SuppressLint("SetTextI18n")
    private void initView_dababy(){

        String channel = Othe_dababyrsInfo.getInstance_dababy().getChannel_dababy();

        //获取图标
        Bitmap logoBm = App_dababyShow_dababyCustomize.getInstance_dababy().getChannelLogoByValue_dababy(channel);
        if (logoBm!=null) logoIv_dababy.setImageBitmap(logoBm);

        mobileTv_dababy.setText(mobile_dababy);
        channelTv_dababy.setText(channel);

        v6482();
        cancelBtn_dababy.setOnClickListener(v -> {
            if (denyRunnable_dababy !=null) denyRunnable_dababy.run();
            dismiss();
        });

        okBtn_dababy.setOnClickListener(v -> {
            if (addAccountRunnable_dababy !=null) addAccountRunnable_dababy.run();
            dismiss();
        });

    }


}
